<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var arrA = [1, 2, 3, 1, 1, 1, 2, 2, 3, 3, 4];

      var arr = arrA.reduce(function (pre, cur) {
        if(cur in pre){
            pre[cur] += 1;

        }else {
            pre[cur]=+1
        }
        return pre
      }, {});
 console.log(arr)
  for(var i in arr){
      console.log(i+"出现的次数"+arr[i])
  }

    
    </script>
  </body>
</html>
